package com.supor.aiot.basket.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.supor.aiot.basket.R;
import com.supor.aiot.basket.bean.SelectedTextBean;

import java.util.List;


public class BasketTextAdapter extends RecyclerView.Adapter<BasketTextAdapter.BasketHolder>{
    private List<SelectedTextBean> mList;
    private Context mContext;


    public BasketTextAdapter(List<SelectedTextBean> mList, Context mContext) {
        this.mList = mList;
        this.mContext = mContext;
    }

    @NonNull
    @Override
    public BasketTextAdapter.BasketHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(mContext).inflate(R.layout.item_ingredients_outer,parent, false);
        return new BasketTextAdapter.BasketHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull BasketHolder holder, int position) {
        SelectedTextBean bean = mList.get(position);
        holder.tvHideName.setText(bean.getDesc());
        if (bean.isSelected()){
            holder.tvHideName.setTextColor(mContext.getResources().getColor(R.color.content_default));
        }else {
            holder.tvHideName.setTextColor(mContext.getResources().getColor(R.color.content_assist));
        }
    }



    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class BasketHolder extends RecyclerView.ViewHolder{
        private TextView tvHideName;
        public BasketHolder(@NonNull View itemView) {
            super(itemView);
            tvHideName = itemView.findViewById(R.id.tv_ingredients_name);
        }
    }


}
